#!/usr/bin/env bash

# 当使用未初始化的变量时，程序自动退出
set -u

# 当任何一行命令执行失败时，自动退出脚本
set -e

# 在运行结果之前，先输出执行的那一行命令
set -x

BOOK_PATH="/Users/dolphin/Library/Mobile Documents/com~apple~CloudDocs/Document/source/dolphin/summary/dolphin-book-2020"

PID_COUNT=`ps -ef | grep ""dolphin-book-2020.tex" | grep -v "grep" | wc -l`
if [[ ${PID_COUNT} -lt 1 ]]; then
  `nohup /Library/TeX/texbin/latexmk -pdfxe -pvc -xelatex -interaction=nonstopmode dolphin-book-2020.tex`
else
    echo "process already exists..."
fi